//验证码
let parm = {
	id: "v_container",
	canvasId: "list"
}
//let parms = {
//	id: "v_containers",
//	canvasId: "lists"
//}
var verifyCode = new GVerify(parm);
//var verifyCodee = new GVerify(parms);
//图形验证码
document.getElementById("code_input").onblur = function() {
	var res = verifyCode.validate(document.getElementById("code_input").value);
	if(res) {
		$('.tucodename').html('')
	} else {;
		$('.tucodename').html('验证码错误')
	}
}
//document.getElementById("myy_button").onclick = function() {
//	var res = verifyCodee.validate(document.getElementById("code_inputt").value);
//	if(res) {
//		alert("验证正确");
//	} else {
//		alert("验证码错误");
//	}
//}

//选项卡
$('.guide_c:eq(0)').show()
$('.guide div').mousemove(function() {
	var index = $(this).index()
	$(this).addClass('on').siblings().removeClass('on')
	$('.guide_c').hide().eq(index).show()
})

//获取验证码
var wait=60;
function time(o) {
  if (wait == 0) {
   o.removeAttribute("disabled");   
   o.value="获取验证码";
   wait = 60;
  } else { 
 
   o.setAttribute("disabled", true);
   o.value= wait + "S";
   wait--;
   setTimeout(function() {
    time(o)
   },
   1000)
  }
 }

$('#btn').click(function() {
		
	if( $('.phone').val().length == 11 && $('.phone').val() !=''){
		time(this)
		$.ajax({
			type: "post",
			url: URLS.interface.code,
			data: {
				phone: $('.phone').val()
			},
			success: function(e) {
//				console.log(e)
			}
		})
	}else{
		$('.phonename').html('请输入账号')
	}	

})

//账户
$('.phone').blur(function(){
	if($('.phone').val().length == 11 && $('.phone').val() !='' ){
		$('.phonename').html('')
	}else{
		$('.phonename').html('请输入账号')
	}
})

//验证码
$('.code').blur(function(){
	if($('.code').val() !='' ){
		$('.codename').html('')
	}else{
		$('.codename').html('请输入验证码')
	}
})

//登录
$('#my_button').click(function(){
	if($('.phone').val() ==''){
		$('.phonename').html('请输入账号')
	}else{
		$('.phonename').html('')
	}
	
	if($('.code').val() ==''){
		$('.codename').html('请输入验证码')
	}else{
		$('.codename').html('')
	}
	
	if($('.tucode').val() ==''){
		$('.tucodename').html('请输入图形验证码')
	}else{
		$('.tucodename').html('')
	}
	
	if($('.phone').val() !='' && $('.code').val() !='' && $('.tucode').val() !=''){
		$.ajax({
			type:'post',
			url:URLS.interface.login,
			data:{
				phone: $('.phone').val(),
				code:$('.code').val(),
				appId:'wap'
			},
			success:function(e){
				if(e.code == '10000'){	
					localStorage.setItem('token',e.data.token);
					window.location.href = './html/index.html';
				}else{
					$('.tucodename').html(e.msg);
				}
			}
		})
	}
	
})
